/**
 * 
 */
package org.velocity;

import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.Properties;

import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;

/**
 * @author LionBule
 * 2011-5-4 ����09:51:07
 */
public class SimpleVelocity {
	public static void main(String[] args) throws Exception {
		VelocityEngine veloEngine = new VelocityEngine();
		Properties p = new Properties();
		p.load(SimpleVelocity.class.getResourceAsStream("/velocity.properties"));
		// ����jar.resource.loader.path
		//String jarFile = "jar:file:"+ SimpleVelocity.class.getProtectionDomain().getCodeSource().getLocation().getFile();
		//p.put("jar.resource.loader.path", jarFile);
		
		//class
		p.put("resource.loader", "class");
		p.put("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
		veloEngine.init(p);
		
		
		Template template = veloEngine.getTemplate("/vm/test.vm");
		
		OutputStream fos = new FileOutputStream("/home/vm.html");
		OutputStreamWriter osw = new OutputStreamWriter(fos);
		
		VelocityContext context = new VelocityContext();
		context.put("data", "���� test1111");
		
		template.merge(context, osw);
		
		osw.close();
		fos.close();
	}

}
